package org.csu.sei.entity.DTO;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import org.csu.sei.entity.News;

import java.time.LocalDateTime;

@Data
public class NewsDTO {
    private Long id;
    private Long catId;
    private String catName;
    private String title;
    private String smailTitle;
    private String keywords;
    private String description;
    private String img;
    private int listOrder;
    private int newsStatus;
    private String copyFrom;
    private String authorName;
    private int count;
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    private NewsDTO (News news,String catName){
        this.id = news.getId();
        this.catId = news.getCatId();
        this.title = news.getTitle();
        this.smailTitle = news.getSmailTitle();
        this.keywords = news.getKeywords();
        this.description = news.getDescription();
        this.img = news.getImg();
        this.listOrder = news.getListOrder();
        this.newsStatus = news.getNewsStatus();
        this.copyFrom = news.getCopyFrom();
        this.authorName = news.getAuthorName();
        this.count = news.getCount();
        this.catName = catName;
        this.createTime = news.getCreateTime();
        this.updateTime = news.getUpdateTime();
    }

    public static NewsDTO returnNews(News news,String catName){
        return new NewsDTO(news,catName);
    }
}
